<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.List,java.util.Map;" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="<%=request.getContextPath()%>/public/css/style.model.css">
<!-- core -->
<script src="<%=request.getContextPath()%>/public/js/jquery-1.5.1.min.js"></script>
<!-- dataTable -->
<script src="<%=request.getContextPath()%>/public/js/jquery-ui-1.8.13.custom.min.js"></script>
<!-- dataTable -->
<script src="<%=request.getContextPath()%>/public/js/jquery.dataTables.js"></script>
</head>
<body>
<div class="container">
<h2>${model.m_title }/${model.m_view }</h2>
<div class="toolbar">
	<ul><li><a id="" class="save-btn" href="<%=request.getContextPath()%>/c?${ model.m_action }&m_id=${model.m_id }&o=form&p=add">添加</a></li></ul>
	<div class="cl"></div>
</div>
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
	<thead>
		<tr>
		<th>操作</th>
		<c:forEach var="control" items="${controls }" >
		<c:if test="${control.mc_pri }">
		<c:set var="pri" value="${control.mc_attr_name }" scope="request"/>
		</c:if>
		<c:if test="${control.mc_show}">
			<c:if test="${!control.mc_auto }">
			<th>${control.mc_prompt}</th>
			</c:if>
		</c:if>
		</c:forEach>
		</tr>
	</thead>
	<tbody>
	<c:set var="f" value="1" />
	<c:forEach var="e" items="${es }">
	<c:set var="entry" value="${e }" scope="request"/>
	<% Map<String,Object> entry =  ((Map<String,Object>)request.getAttribute("entry")); %>
	<c:set var="f" value="${f+1 }" />
	<tr class='grade<c:if test="${f%2==0}">B</c:if><c:if test="${f%2!=0}">A</c:if>'>
		<td>
		<a href="<%=request.getContextPath()%>/c?${ model.m_action }&key=<%= entry.get(request.getAttribute("pri").toString()) %>&pri=${pri }&o=form&p=edit&m_id=${model.m_id }&v=${model.m_view}" class="edit">&nbsp;</a>
		<a href="<%=request.getContextPath()%>/c?${ model.m_action }&key=<%= entry.get(request.getAttribute("pri").toString()) %>&pri=${pri }&o=delete&m_id=${model.m_id }&v=${model.m_view}" class="delete">&nbsp;</a>
		</td>
		<c:forEach var="control" items="${controls }" >
		<c:if test="${control.mc_show}">
			<c:if test="${!control.mc_auto }">
			 <c:set var="c" value="${control.mc_attr_name}" scope="request"/>
			<td><%= entry.get(request.getAttribute("c").toString()) %></td>
			</c:if>
		</c:if>
		</c:forEach>
	</tr>
	</c:forEach>
		
	</tbody>
</table>
</div>
<script type="text/javascript">
	$().ready(function(){$("#example").dataTable({
        "bJQueryUI": true,
        "sPaginationType": "full_numbers"
    });
	$(".delete").each(function(){
		$(this).click(function(){
			if(confirm('确定要删除该条实例么?'))
				return true;
			return false;
		});
	});
	<c:if test="${msg!=null}">alert('${msg}');</c:if>
	});
</script>
</body>
</html>